package com.bq.gametrade.ui.fragment;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.bq.gametrade.R;
import com.bq.gametrade.ui.activity.GuideActivity;
import com.bq.gametrade.ui.dialog.PermissionPromptDialog;
import com.bq.gametrade.utils.SharedPreferencesUtils;

/**
 * @author Feel on 2016/11/28 10:31
 */

public class GuideNextFragment extends Fragment{

    private Button btnNext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_guide_next,null);

        btnNext = (Button) view.findViewById(R.id.btn_next);
        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferencesUtils.saveValue(getActivity(),SharedPreferencesUtils.first_login,true);

                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
                    PermissionPromptDialog dialog = new PermissionPromptDialog();
                    dialog.show(getFragmentManager(),"dialog");
                    dialog.setNextClickListener(new PermissionPromptDialog.OnNextClickListener() {
                        @Override
                        public void onNextListener() {
                            GuideActivity activity = (GuideActivity)getActivity();
                            activity.entryApp();
                            activity.finish();
                        }
                    });
                }else {
                    GuideActivity activity = (GuideActivity)getActivity();
                    activity.entryApp();
                    activity.finish();

                }

            }
        });
        return view;
    }

}
